## This code creates Table A4.

# Table A4

data <- colonial_towns_shp

houses_raw_OLS <- lm(pop_1783~replaced+as.factor(district),data=data@data)
houses_full_OLS <- lm(pop_1783~replaced+as.factor(district)+altitude+slope_idx+as.factor(soil_quality)+log(yangon_dist)+log(river_dist)+longitude_2+latitude_2,data=data@data)
houses_logged_OLS <- lm(log(pop_1783)~replaced+as.factor(district)+altitude+slope_idx+as.factor(soil_quality)+log(yangon_dist)+log(river_dist)+longitude_2+latitude_2,data=data@data)

houses_specs <- c("houses_raw_OLS","houses_full_OLS","houses_logged_OLS")

houses_table <- matrix(nrow = 7,ncol=4)

for(i in 1:length(houses_specs)){
  houses_table[1,i+1] <- houses_specs[i]
  model <- get(houses_specs[i])
  coef <- round(summary(model)$coefficients[2],digits=4)
  se <- round(summary(model)$coefficients[2,2],digits=4)
  houses_table[2,i+1] <- coef
  houses_table[3,i+1] <- paste0("(",se,")")
  houses_table[4,i+1] <- paste0("[",round(coef-1.96*se,digits=4),",")
  houses_table[5,i+1] <- paste0(round(coef+1.96*se,digits=4),"]")
  houses_table[6,i+1] <- nobs(model)
  houses_table[7,i+1] <- round(summary(model)$adj.r.squared,digits=4)
}

xtable(houses_table)


